<?php

class locations_Model_DbTable_DbLocation extends Zend_Db_Table_Abstract
{
	public function addLocation($data){
		$db = $this->getAdapter();
		$this->_name ="tbwu_location";
		$db->getProfiler()->setEnabled(true);
		$arr = array(
			'location_name'	=> $data["location_name"],
			'status'		=> $data["status"],
			'user_id'		=>1,
			'created_date'	=> new Zend_Date()
		);
		$this->insert($arr);
		Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQuery());
		Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQueryParams());
		$db->getProfiler()->setEnabled(false);
	}
	
	public function editLocation($data){
		$db = $this->getAdapter();
		$db->getProfiler()->setEnabled(true);
		$id = $data["id"];
		$arr = array(
				'location_name'	=> $data["location_name"],
				'status'		=> $data["status"],
				'user_id'		=>1,
		);
		$this->_name = "tbwu_location";
		$where = $db->quoteInto("location_id=?", $id);
		$this->update($arr, $where);
		
		Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQuery());
		Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQueryParams());
		$db->getProfiler()->setEnabled(false);
	}
	
	public function deleteLocation($data){
		$db = $this->getAdapter();
		$sql ="DELETE FROM tbwu_location WHERE location_id=$data";
		$db->query($sql);
	}
}

